/*
date:20210315 pm18:20
key:1.数组内每nb个取出为一组，(i + 1) % nb == 0。
2.
*/
#include<math.h>
#include <algorithm>
#include <stdio.h>
#include<iostream>
#include<sstream>
#include<stack>
#include<stdlib.h>
#include<stack>
#include<vector>
using namespace std;
const int P = 10007;
void change(int& a, int& b)
{
	int k = b;
	b = a;
	a = k;
}

int* divide(int* A,int n,int groups)
{
	//分成g组
	int i;
	int nb = n / groups;//每组的个数
	int* D = new int[n];
	vector<int>C;
	stack<int>B;
	//整体翻转，第一次没发生，第二次发生了，题意不明
	for (i = 0;i < n; i++)
	{
		B.push(A[i]);
	
		if ((i + 1) % nb == 0)
		{
			while (!B.empty())//组内翻转
			{
				C.push_back(B.top());
				cout << B.top();
				B.pop();
			}
		}


	}
	//从vector给到int*
	for (i = 0; i < n; i++)
	{
		D[i] = C[i];
	}
	return D;
}
int main()
{
	//6 8 3 4 1 2 5
	int i,u, n,m;
	cin >> n;
	n = pow(2, n);
	int* A = new int[n];
	for (i = 0; i < n; i++)
	{
		cin >> A[i];
	}
	cin >> m;
	for (i = 0; i < m; i++)
	{
		//划分u组
		cin >> u;
		A=divide(A, n, pow(2, u));
		cout << "\n";
	}
}
